<?php
import ( "@.ORG.Page" );
class AdminlogAction extends Action {

	private $Adminlog;

	public function __construct(){
		parent::__construct();
		$this->Adminlog = M('Adminlog');
	}

    public function index(){
    	header("Content-Type:text/html;charset=utf-8");
    	$nickname = urldecode($_REQUEST['nickname']);
    	$where = array();
    	if($nickname!=''){
    		$where['nickname'] = $nickname;
    	}
		$logs = $this->Adminlog->where($where)->select();
		$count =count($logs);
    	$p  = new Page ( $count, C('PAGE_SIZE') );
		$logs   = $this->Adminlog->where($where)->order('addtime desc')->limit($p->firstRow . ',' . $p->listRows)->findAll();
		$len = count($logs);
		if($logs){
			for($i=0; $i<$len; $i++ ){
				$logs[$i]['ename'] = urlencode($logs[$i]['nickname']);
			}
		}
		$page = $p->show();
		$this->assign('logs',$logs);
		$this->assign('page',$page);
		$this->display('logList');
    }

    public function foreverdelete() {
		//删除指定记录
		$name=$this->getActionName();
		$model = D ($name);
		if (! empty ( $model )) {
			$pk = $model->getPk ();
			$id = $_REQUEST [$pk];
			if (isset ( $id )) {
				$condition = array ($pk => array ('in', explode ( ',', $id ) ) );
				if (false !== $model->where ( $condition )->delete ()) {
					//echo $model->getlastsql();
					$this->success ('删除成功！');
				} else {
					$this->error ('删除失败！');
				}
			} else {
				$this->error ( '非法操作' );
			}
		}
		$this->forward ();
	}
}
?>